/*
  Spi.h - SPI library
  Copyright (c) 2008 Cam Thompson.
  Author: Cam Thompson, Micromega Corporation, <www.micromegacorp.com>
  Version: December 15, 2008

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

/*
  updated by Alexis 26th oct 2009
  configured for Arduino Mega
  
  Use only for MCP4922 Analog to Digital Converter
*/

#ifndef Spi_h
#define Spi_h

#include "WProgram.h"

#define SCK_PIN   52 //SPI Clock
#define MISO_PIN  50 //SPI output (data going to DAC)
#define MOSI_PIN  51 //SPI input (data comming from DAC, here not connected) 
#define SS1_PIN   53 //Chip Select of the first DAC (mirrors)
#define SS2_PIN   49 //Chip Select of the second DAC (red Laser)

class SPI
{
  public:
    SPI(void);
	void writeOutX(int value);
	void writeOutY(int value);
	void writeOutR(int value);
	
		
  private:
    void mode(byte);
    byte transfer(byte);
    byte transfer(byte, byte);
	void transfer16Bit(byte, byte);
};

extern SPI Spi;

#endif
